﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_GetUserFromSessionID')
	BEGIN
		DROP  Procedure  [esf_sso].P_GetUserFromSessionID
	END

GO

CREATE Procedure [esf_sso].P_GetUserFromSessionID
	@pSessionID		UNIQUEIDENTIFIER
AS

	SELECT 
		VU.*
	FROM
		[esf_sso].VUser VU
	INNER JOIN
		[esf_sso].UserSessionLog USL ON USL.UserPersonID = VU.Usr_Per_ID
	WHERE
		USL.ID = @pSessionID
		AND USL.EndDateTime IS NULL

GO